<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>alwayson</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="alpass.html" title="alpass" />
    <link rel="next" href="ampdb.html" title="ampdb" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">alwayson</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="alpass.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ampdb.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="alwayson"></a>
      <div class="titlepage"></div>
      <a id="Indexalwayson" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">alwayson</span>
        </h2>
        <p>alwayson — 
      Activates the indicated instrument in the orchestra header,
      without need for an i statement.     
    </p>
      </div>
      <div class="refsect1">
        <a id="idp89629040"></a>
        <h2>Description</h2>
        <p>
      Activates the indicated instrument in the orchestra header,
      without need for an i statement. Instruments must be 
      activated in the same order as they are defined.
    </p>
        <p>
      The alwayson opcode is designed to simplify 
      the definition of re-usable orchestras with 
      signal processing or effects chains and networks.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp89630960"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"> <span class="command"><strong>alwayson</strong></span> Tinstrument [p4, ..., pn]</pre>
      </div>
      <div class="refsect1">
        <a id="idp89633152"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>Tinstrument</em></span> -- String name of the instrument definition to be turned on.
    </p>
        <p>
      <span class="emphasis"><em>[p4, ..., pn]</em></span> -- Optional pfields to be passed to the instrument, in the same
      order and type as if this were an i statement.
    </p>
        <p>
      When the instrument is activated, p1 is the insno, p2 is 0, and p3 is -1.
      Pfields from p4 on may optionally be sent to the instrument.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp89636304"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the alwayson opcode. It uses the file <a class="ulink" href="examples/alwayson.csd" target="_top"><em class="citetitle">alwayson.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp89638160"></a>
          <p class="title">
            <strong>Example 49. Example of the alwayson opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">;-Wfo alwayson.wav </span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
 

<span class="comment">; Initialize the global variables. </span>

<span class="ohdr">sr</span>     <span class="op">=</span> 44100 
<span class="ohdr">ksmps</span> 	<span class="op">=</span> 32 
<span class="ohdr">nchnls</span> 	<span class="op">=</span> 2 

<span class="comment">; Connect up instruments and effects to create the signal flow graph. </span>

<span class="opc">connect</span> "SimpleSine",   	"leftout",     "Reverberator",     	"leftin" 
<span class="opc">connect</span> "SimpleSine",   	"rightout",    "Reverberator",     	"rightin" 

<span class="opc">connect</span> "Moogy",        	"leftout",     "Reverberator",     	"leftin" 
<span class="opc">connect</span> "Moogy",        	"rightout",    "Reverberator",     	"rightin" 

<span class="opc">connect</span> "Reverberator", 	"leftout",     "Compressor",       	"leftin" 
<span class="opc">connect</span> "Reverberator", 	"rightout",    "Compressor",       	"rightin" 

<span class="opc">connect</span> "Compressor",   	"leftout",     "Soundfile",       	"leftin" 
<span class="opc">connect</span> "Compressor",   	"rightout",    "Soundfile",       	"rightin" 

<span class="comment">; Turn on the "effect" units in the signal flow graph. </span>

<span class="opc">alwayson</span> "Reverberator", 0.91, 12000 
<span class="opc">alwayson</span> "Compressor" 
<span class="opc">alwayson</span> "Soundfile" 

<span class="comment">; Define instruments and effects in order of signal flow.</span>

			    <span class="oblock">instr</span> SimpleSine 
                <span class="comment">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
			    <span class="comment">; Default values:   p1  p2  p3  p4  p5  p6  p7  p8  p9  p10</span>
			    <span class="opc">pset</span>			    0,  0,  10, 0,  0,  0,  0.5
iattack			<span class="op">=</span>			        0.015
idecay			<span class="op">=</span>			        0.07
isustain		<span class="op">=</span>			        p3
irelease		<span class="op">=</span>			        0.3
p3			    <span class="op">=</span>			        iattack <span class="op">+</span> idecay <span class="op">+</span> isustain <span class="op">+</span> irelease
adamping		<span class="opc">linsegr</span>			    0.0, iattack, 1.0, idecay <span class="op">+</span> isustain, 1.0, irelease, 0.0
iHz 			<span class="op">=</span> 			        <span class="opc">cpsmidinn</span>(p4) 
                <span class="comment">; Rescale MIDI velocity range to a musically usable range of dB. </span>
iamplitude 		<span class="op">=</span> 			        <span class="opc">ampdb</span>(p5 <span class="op">/</span> 127 <span class="op">*</span> 15.0 <span class="op">+</span> 60.0) 
			    <span class="comment">; Use ftgenonce instead of ftgen, ftgentmp, or f statement. </span>
icosine			<span class="opc">ftgenonce</span> 		    0, 0, 65537, 11, 1 
aoscili			<span class="opc">oscili</span> 			    iamplitude, iHz, icosine 
aadsr 			<span class="opc">madsr</span> 			    iattack, idecay, 0.6, irelease 
asignal 		<span class="op">=</span> 			        aoscili <span class="op">*</span> aadsr 
aleft, aright	<span class="opc">pan2</span>			    asignal, p7
			    <span class="comment">; Stereo audio output to be routed in the orchestra header. </span>
			    <span class="opc">outleta</span> 		    "leftout", aleft
			    <span class="opc">outleta</span> 		    "rightout", aright
			    <span class="oblock">endin</span> 

			    <span class="oblock">instr</span> Moogy 
                <span class="comment">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
			    <span class="comment">; Default values:   p1  p2  p3  p4  p5  p6  p7  p8  p9  p10</span>
			    <span class="opc">pset</span>			    0,  0,  10, 0,  0,  0,  0.5
iattack			<span class="op">=</span>			        0.003
isustain		<span class="op">=</span>			        p3
irelease		<span class="op">=</span>			        0.05
p3			    <span class="op">=</span>			        iattack <span class="op">+</span> isustain <span class="op">+</span> irelease
adamping		<span class="opc">linsegr</span>			    0.0, iattack, 1.0, isustain, 1.0, irelease, 0.0
iHz 			<span class="op">=</span> 			        <span class="opc">cpsmidinn</span>(p4)
                <span class="comment">; Rescale MIDI velocity range to a musically usable range of dB. </span>
iamplitude 		<span class="op">=</span> 			        <span class="opc">ampdb</span>(p5 <span class="op">/</span> 127 <span class="op">*</span> 20.0 <span class="op">+</span> 60.0) 
			    <span class="opc">print</span> 			    iHz, iamplitude 
			    <span class="comment">; Use ftgenonce instead of ftgen, ftgentmp, or f statement. </span>
isine 			<span class="opc">ftgenonce</span> 		    0, 0, 65537, 10, 1 
asignal 		<span class="opc">vco</span> 			    iamplitude, iHz, 1, 0.5, isine 
kfco 			<span class="opc">line</span> 			    2000, p3, 200
krez 			<span class="op">=</span> 			        0.8 
asignal 		<span class="opc">moogvcf</span> 		    asignal, kfco, krez, 100000 
asignal			<span class="op">=</span>			        asignal <span class="op">*</span> adamping
aleft, aright	<span class="opc">pan2</span>			    asignal, p7
			    <span class="comment">; Stereo audio output to be routed in the orchestra header. </span>
			    <span class="opc">outleta</span> 		    "leftout", aleft
			    <span class="opc">outleta</span> 		    "rightout", aright 
			    <span class="oblock">endin</span> 
			    <span class="oblock">instr</span> Reverberator 
                <span class="comment">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
			    <span class="comment">; Stereo input. </span>
aleftin 		<span class="opc">inleta</span> 			    "leftin" 
arightin 		<span class="opc">inleta</span> 			    "rightin" 
idelay 			<span class="op">=</span> 			        p4 
icutoff 		<span class="op">=</span> 			        p5 
aleft, aright 	<span class="opc">reverbsc</span> 	        aleftin, arightin, idelay, icutoff 
			    <span class="comment">; Stereo output. </span>
			    <span class="opc">outleta</span> 	        "leftout", aleft 
			    <span class="opc">outleta</span> 	        "rightout", aright 
			    <span class="oblock">endin</span> 

			    <span class="oblock">instr</span> Compressor 
                <span class="comment">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
			    <span class="comment">; Stereo input. </span>
aleftin 		<span class="opc">inleta</span> 		        "leftin" 
arightin 		<span class="opc">inleta</span> 		        "rightin" 
kthreshold 		<span class="op">=</span> 		            25000 
icomp1 			<span class="op">=</span> 		            0.5 
icomp2 			<span class="op">=</span> 		            0.763 
irtime 			<span class="op">=</span> 		            0.1 
iftime 			<span class="op">=</span> 		            0.1 
aleftout 		<span class="opc">dam</span> 		        aleftin, kthreshold, icomp1, icomp2, irtime, iftime 
arightout 		<span class="opc">dam</span> 		        arightin, kthreshold, icomp1, icomp2, irtime, iftime 
			    <span class="comment">; Stereo output. </span>
			    <span class="opc">outleta</span> 	        "leftout", aleftout 
			    <span class="opc">outleta</span> 	        "rightout", arightout 
			    <span class="oblock">endin</span> 

			    <span class="oblock">instr</span> Soundfile 
                <span class="comment">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span>
			    <span class="comment">; Stereo input. </span>
aleftin 		<span class="opc">inleta</span> 		        "leftin" 
arightin 		<span class="opc">inleta</span> 		        "rightin" 
			    <span class="opc">outs</span> 		        aleftin, arightin 
			    <span class="oblock">endin</span> 

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 

<span class="comment">; It is not necessary to activate "effects" or create f-tables in the score! </span>
<span class="comment">; Overlapping notes create new instances of instruments with proper connections. </span>

<span class="stamnt">i</span> "S<span class="stamnt">i</span>mpleS<span class="stamnt">i</span>ne" 1 5 60 85 
<span class="stamnt">i</span> "S<span class="stamnt">i</span>mpleS<span class="stamnt">i</span>ne" 2 5 64 80 
<span class="stamnt">i</span> "Moogy" 3 5 67 75 
<span class="stamnt">i</span> "Moogy" 4 5 71 70 
<span class="comment">; 1 extra second after the performance</span>
<span class="stamnt">e</span> 1 

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp89640080"></a>
        <h2>Credits</h2>
        <p>By: Michael Gogins 2009</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="alpass.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ampdb.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">alpass </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ampdb</td>
        </tr>
      </table>
    </div>
  </body>
</html>
